
import '@/map/cesium/lib/cesium-measure'
export default {
    name: 'ZoomMeasure',
    data() {
        return {
            measure: null,
            clampToGround: true
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.measure = new Cesium.Measure(this.$viewer)
        })
    },
    methods: {

        measureLineC() {
            const cesiumContainer = document.getElementById('cesiumContainer')
            // 销毁其它事件
            this.$store.dispatch('isDrawing', true)
            cesiumContainer.style.cursor = 'crosshair'
            this.measure.drawLineMeasureGraphics({
                clampToGround: this.clampToGround,
                callback: () => {
                    this.$store.dispatch('isDrawing', false)
                }
            })
        },

        measureAreaC() {
            const cesiumContainer = document.getElementById('cesiumContainer')
            // 销毁其它事件
            this.$store.dispatch('isDrawing', true)
            cesiumContainer.style.cursor = 'crosshair'
            this.measure.drawAreaMeasureGraphics({
                clampToGround: this.clampToGround,
                callback: (arr, polyObj) => {
                    this.$store.dispatch('isDrawing', false)
                }
            })
        },

        clearC() {
            this.measure._drawLayer.entities.removeAll()
        }
    }
}
